<template>
  <div id="tmpl">
     <div class="title">
         <h3>{{list.title}}</h3>
         <p>
             <span>发表时间：{{list.add_time | datefmt("YYYY-MM-DD")}}</span>
             <span>点击数量：{{list.click}}</span>
         </p>
     </div>
     <div class="content" v-html="list.content">
     </div>
     <comment :id="id"></comment>
  </div>
</template>
<script>
import { Toast } from "mint-ui";
import comment from "../subcom/comment.vue";
export default {
  components: {
    comment
  },
  data() {
    //es6语法等同data:function(){}
    return {
      list: {},
      id:0
    };
  },
  created() {
      this.id=this.$route.params.id //参数有路由插件后生成,id最后再也页面生成后传递
      this.getinfo();
  },
  methods: {
    getinfo() {
      /* var params = this.$route.params.id; //参数有路由插件后生成
      this.id=params; */
      var url = `/api/getnew/${this.id}`; //用es6语法字符串拼接
      this.$axios.get(url).then(res => {
        //用es6语法等同function（）{}
        //console.log(res);
        var data = res.data;
        if (data.status != 0) {
          Toast(data.message);
          return;
        }
        this.list = data.message[0];
      });
    }
  },
};
</script>
<style scoped lang="less">
div {
  padding: 10px;
}
.title p {
  color: #0094ff;
}
</style>

